﻿/*
Digraph (library for building, traversal, comparison and saving of directed
graph).

Copyright (C) 2014 Dmitry Merzagitovich Arslanov

This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option) any
later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*/

using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace Digraph
{
    /// <summary>
    /// Contains changes which need to be made to receive a result digraph from
    /// an initial digraph.
    /// </summary>
    public sealed class Difference<TVertex, TArc>
    {
        internal List<Vertex<TVertex, TArc>> AddedVertexList;

        /// <summary>
        /// Vertices are added to initial digraph.
        /// </summary>
        public ReadOnlyCollection<Vertex<TVertex, TArc>> AddedVertices
        {
            get
            {
                return AddedVertexList.AsReadOnly();
            }
        }

        internal List<Vertex<TVertex, TArc>> RemovedVertexList;

        /// <summary>
        /// Vertices are removed from initial digraph.
        /// </summary>
        public ReadOnlyCollection<Vertex<TVertex, TArc>> RemovedVertices
        {
            get
            {
                return RemovedVertexList.AsReadOnly();
            }
        }

        internal List<Arc<TVertex, TArc>> AddedArcList;

        /// <summary>
        /// Arcs are added to initial digraph.
        /// </summary>
        public ReadOnlyCollection<Arc<TVertex, TArc>> AddedArcs
        {
            get
            {
                return AddedArcList.AsReadOnly();
            }
        }

        internal List<Arc<TVertex, TArc>> RemovedArcList;

        /// <summary>
        /// Arcs are removed from initial digraph.
        /// </summary>
        public ReadOnlyCollection<Arc<TVertex, TArc>> RemovedArcs
        {
            get
            {
                return RemovedArcList.AsReadOnly();
            }
        }

        /// <summary>
        /// Indicates that there is no differences between initial and result
        /// digraph.
        /// </summary>
        public bool IsEmpty
        {
            get
            {
                return AddedVertexList.Count == 0 &&
                       RemovedVertexList.Count == 0 &&
                       AddedArcList.Count == 0 &&
                       RemovedArcList.Count == 0;
            }
        }

        internal Difference()
        {
            AddedVertexList = new List<Vertex<TVertex, TArc>>();
            RemovedVertexList = new List<Vertex<TVertex, TArc>>();
            AddedArcList = new List<Arc<TVertex, TArc>>();
            RemovedArcList = new List<Arc<TVertex, TArc>>();
        }
    }
}
